var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
const defaultOptions = {
  title: "",
  message: "",
  cancelText: "\u53D6\u6D88",
  cancelColor: "#84878F",
  showCancel: false,
  confirmText: "\u786E\u5B9A",
  confirmColor: "#F7931E"
};
const formatOptions = (o) => {
  const opt = __spreadValues({}, defaultOptions);
  if (typeof o === "string") {
    o = Object.assign(opt, { message: o });
  } else {
    o = Object.assign(opt, o);
  }
  return {
    title: o.title,
    content: o.message,
    showCancel: o.showCancel,
    cancelText: o.cancelText,
    cancelColor: o.cancelColor,
    confirmText: o.confirmText,
    confirmColor: o.confirmColor
  };
};
const dialog = (options, showCancel = false) => {
  return new Promise((resolve, reject) => {
    uni.showModal(__spreadProps(__spreadValues({}, formatOptions(options)), {
      showCancel,
      success: ({ confirm }) => {
        confirm ? resolve("confirm") : reject("cancel");
      },
      fail: (e) => {
        console.info("showModal fail:", e);
      }
    }));
  });
};
dialog.confirm = (options) => {
  return dialog(options, true);
};
export {
  dialog
};
